<template>
  <div id="main">
    <input
      @blur="blurEventHandle"
      @focus="focusEventHandle"
      class="input w-h-full"
    />
    <div
      :isfocus="isFocus ? 'True' : 'False'"
      id="placeholder"
      class="p-1"
    >
      {{ placeholder }}
    </div>
  </div>
</template>

<script lang="ts" setup>
defineProps({
  placeholder: {
    type: String,
    default: "Input...",
  },
});
const isFocus = ref(false);

const blurEventHandle = () => (isFocus.value = false);
const focusEventHandle = () => (isFocus.value = true);
</script>

<style lang="scss" scoped>
#main {
  border: 1px solid var(--color);
  position: relative;
}
#placeholder {
  font-size: 1rem;
  line-height: 1rem;
  position: absolute;
  top: calc(50% - 0.75rem);
  left: 1rem;
  transition: all 0.15s ease;

  &[isfocus="True"] {
    top: calc(0px - 0.75rem);
    left: 1rem;
    transition: all 0.15s ease;
    font-size: 0.7rem;
    // color: red;
  }
  background-color: var(--bg);
}

.input {
  outline: none;
  border: none;
  &:focus {
    border: none;
  }

  &:focus-within {
    border: none;
  }
}
</style>
